const { Model } = require('../index');

class UserTag extends Model {
    static get tableName() {
        return 'user_tag';
    }

    static get relationMappings() {

        return {
            //  a user_tag belongs to a user
            user: {
                relation: Model.BelongsToOneRelation,
                modelClass: `${__dirname}/user.js`,
                // Where the two are joined
                join: {
                    from: 'user_tag.userId',
                    to: 'user.id'
                }
            },
            //  A user_tag maps to many user_stock_tag
            user_tag: {
                relation: Model.HasManyRelation,
                modelClass: `${__dirname}/user_stock_tag.js`,
                // Where the two are joined
                join: {
                    from: 'user.id',
                    to: 'user_tag.userId'
                }
            }
        };
    }
}

module.exports = UserTag;
//a = u.tableName;